<!doctype html>
<title>&lt;img> loading in destroyed document</title>
<iframe></iframe>
<script>
onload = function() {
  const img = new Image();
  img.onload = function() {
    const iframe = document.querySelector('iframe');
    iframe.contentDocument.createElement('div').innerHTML =
      `<picture>
         <source srcset="nonexistent.png">
         <img src="">
       </picture>`;
    iframe.remove();
  };
  img.src = '';
};
</script>
